﻿function refuse_onclick(rad_obj,hdn_obj){
	hdn_obj.value = rad_obj.value;
	if (rad_obj.value == "LD_PHONG_TUCHOI" || rad_obj.value == "LD_PHONG_TRALAI" || rad_obj.value == "LD_COQUAN_TUCHOI" ){
		document.all.tr_reason.style.display='block';
	}else{
		document.forms(0).txt_reason.value = "";
		document.all.tr_reason.style.display='none';
	}
}
function rad_onclick(rad_obj,hdn_obj){
	var f = document.forms(0),e,v_element;
	for (i=0;i<f.length;i++){
		e=f.elements[i];
		v_element = e.name;
		if(v_element == rad_obj.value){
			document.getElementById("worktype").innerHTML=e.value;
		}
	}	
	if (rad_obj.value!=""){ 
		var url="dsp_all_attach_file_by_one_worktype.php?v_worktype_code=" + rad_obj.value;
		xmlHttp=GetXmlHttpObject(stateChanged);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	}else{ 
		document.getElementById("txtHint").innerHTML="";
	}	
	if(rad_obj.value == 'XAC_NHAN_HO_SO'){
		document.forms(0).txt_result.value = "Đã nhận đủ hồ sơ";
	}else{
		document.forms(0).txt_result.value = "";
	}
	hdn_obj.value = rad_obj.value;
}
function Update_record_status(p_fuseaction){
	if (document.forms(0).hdn_work.value == ''){
		alert('Phai xac dinh mot ket qua thu ly');
		return;
	}
	btn_save_onclick(p_fuseaction);
}
function btn_query_onclick(){
	v_current_url = "index.php";
	v_record_id = document.forms(0).hdn_record_id.value;
	v_fuseaction = document.forms(0).fuseaction.value;
	v_recordtype_filter = document.forms(0).hdn_recordtype_filter.value;
	v_current_url = v_current_url + "?fuseaction=" + v_fuseaction + "&hdn_record_id=" + v_record_id + "&hdn_recordtype_filter=" + v_recordtype_filter + "&hdn_query_data=1"
	//alert (v_current_url); 
	window.location = v_current_url;
}
function btn_approve_handler_onclick(p_checkbox_obj, p_hidden_obj, p_fuseaction){
	if (!checkbox_value_to_list(p_checkbox_obj,",")){
		alert("Chua co doi tuong nao duoc chon");
	}	
	else{
		document.forms(0).fuseaction.value = p_fuseaction;
		p_hidden_obj.value = checkbox_value_to_list(p_checkbox_obj,",");
		//var x =  document.f_dsp_all_record_approved.sel_recordtype;
		//document.f_dsp_all_record_approved.value = x.options[x.selectedIndex].text
		document.forms(0).submit(); 
	}	
}
function btn_approving_handler_onclick(p_checkbox_obj, p_hidden_obj, p_fuseaction){
	if (!checkbox_value_to_list(p_checkbox_obj,",")){
		alert("Chua co doi tuong nao duoc chon");
	}	
	else{
		document.forms(0).fuseaction.value = p_fuseaction;
		p_hidden_obj.value = checkbox_value_to_list(p_checkbox_obj,",");
		//var x =  document.f_dsp_all_record_for_approving.sel_recordtype;
		//document.f_dsp_all_record_for_approving.value = x.options[x.selectedIndex].text
		document.forms(0).submit(); 
	}	
}

function show_handler_onclick(p_goto_url,p_fuseaction)
{ 	
	v_url = '';
	//v_url = _DSP_MODAL_DIALOG_URL_PATH;
	v_url = v_url + "?goto_url=" + p_goto_url + "&fuseaction=" + p_fuseaction ;
	v_url = v_url + "&modal_dialog_mode=1" + "&" + randomizeNumber();
	sRtn = showModalDialog(v_url,"","dialogWidth=400pt;dialogHeight=280pt;dialogTop=80pt;status=no;scroll=no;");
	if (!sRtn) 
		sRtn = document.forms[0].txt_handler_name.value;
	document.forms[0].txt_handler_name.value = sRtn;

}
function Get_handler(v_handler_name){
	window.returnValue = v_handler_name;
	window.close();
}

function show_dialog_all_item_onclick(p_goto_url,p_fuseaction, p_text_name_obj, p_text_code_obj, p_hdn_obj, p_hdn_unit_id){
	if (p_hdn_unit_id == ''){
	 alert ('Ban phai chon PHONG THU LY HO SO truoc'); return;
	}
	//alert(p_hdn_unit_id);
	v_url =  p_goto_url + "?hdn_handle_agency_id="+p_hdn_unit_id + "&fuseaction=" + p_fuseaction + "&modal_dialog_mode=1" + "&" + randomizeNumber();
	sRtn = showModalDialog(v_url,"","dialogWidth=420pt;dialogHeight=280pt;dialogTop=80pt;status=no;scroll=no;");
	if (!sRtn) return;
	arr_value = sRtn.split(_LIST_DELIMITOR);
	p_hdn_obj.value = arr_value[0];
	p_text_code_obj.value = arr_value[1];		
	p_text_name_obj.value = arr_value[2];
}
function btn_save_sharing_record_onclick(p_fuseaction){
	if (verify(document.forms(0))){
		document.forms(0).fuseaction.value = p_fuseaction;
		document.forms(0).submit();
	}
}
function re_display_list_handler(){
	v_obj = document.all.tr_handler_name;
	v_check_obj = document.all.chk_handler_list_id;
	primary_handler_id = document.forms(0).hdn_primary_handler_id.value;
	if (v_obj.length>1){
		for(i=0;i<v_obj.length;i++){		
			if (v_obj[i].value == primary_handler_id){
				v_check_obj[i].checked=false;
				v_obj[i].style.display = 'none';
			}
			else
				v_obj[i].style.display = 'block';
		}
	}else{
		if (v_obj.value == primary_handler_id){
			v_check_obj.checked=false;
			v_obj.style.display = 'none';
		}
	}
}
function btn_print_license_onclick(p_goto_url,p_item_id,p_type,p_fuseaction) {
	v_url = p_goto_url + "?hdn_record_id=" + p_item_id + "&hdn_recordtype_filter=" + p_type +"&fuseaction="+p_fuseaction +"&modal_dialog_mode=1";
	v_url = v_url+ "&" + randomizeNumber();
	//sRtn = showModalDialog(v_url,"","dialogWidth=420pt;dialogHeight=200pt;dialogTop=80pt;status=no;scroll=no;");
	goto_url(v_url,3);
}
//ham nay dc dung khi in phieu trinh ky
function show_window_to_print_submit(p_goto_url,p_checkbox_obj,p_type,p_fuseaction) {
	var list = checkbox_value_to_list(p_checkbox_obj,",");
	if (list) {   //Kiem tra xem co ho so nao duoc chon hay khong?
			
			v_url = p_goto_url + "?hdn_record_id_list=" + list+ "&hdn_recordtype_filter=" + p_type +"&fuseaction="+p_fuseaction +"&modal_dialog_mode=1";
			v_url = v_url+ "&" + randomizeNumber();
			//sRtn = showModalDialog(v_url,"","dialogWidth=420pt;dialogHeight=200pt;dialogTop=80pt;status=no;scroll=no;");
			goto_url(v_url,3);
	} else {
		alert("Chua co HO SO nao duoc chon");
		return;		
	}
}
////////////////////
function set_value_for_obj(obj,set_value){
	obj.value = set_value;
}
////////////////////
function test_status_update(obj_status,obj_value,v_num){
	var v_len = obj_status.length;
	if(v_len <= v_num){
		v_num = v_num - 1;
	}
	var v_status = obj_status[v_num].checked;
	var v_content_refuse = obj_value.value;
	if((v_status) && (isblank(v_content_refuse) || (v_content_refuse==""))){
		alert('Ly do tu choi khong the rong. Hoac sai quy trinh');		
		obj_value.focus();
		return false;
	}	
	return true;
}
function btn_save_onclick(p_fuseaction){
	if (_MODAL_DIALOG_MODE==1)
		document.forms(0).action = "index.php?modal_dialog_mode=1";
	else
		document.forms(0).action = "index.php";

	if (verify(document.forms(0))){
		document.forms(0).fuseaction.value = p_fuseaction;
		document.forms(0).submit();
	}	
}
/*
Nguoi viet: Vu Manh Hung
Y nghia:
	Ham nay kien tra truong hop khi NSD chon ngay cap nhat tien do giai quyet la ngay qua khu.
	Tham so:
	v_list_recordtype: Danh sach ma ho so se khong duoc phep cap nhat ngay giai quyet la ngay qua khu?
	v_current_date_value: Nhan gia tri cua ngay hien thoi cua he thong
	obj_date_process: doi tuong textbox luu ngay ma NSD nhap vao
	Vi Du:
	Voi TTHC cap giay cung nhan quyen su dung dat. Chi cho phep NSD cap nhat vao ngay tuong lai
	btn_save_process_onclick('004','05/02/2007','02/02/2007')
	btn_save_process_onclick('001,003,004','05/02/2007','06/02/2007')
*/
function btn_save_process_onclick(v_list_recordtype, v_current_date_value, obj_date_process){
	var v_process_date_value = obj_date_process.value;
	var arr_recordtype = v_list_recordtype.split(",");
	var v_status = 1;
	v_count = arr_recordtype.length;
	for(v_index = 0;v_index<v_count;v_index++){
		if(arr_recordtype[v_index] == '004'){
			if(date_compare(v_current_date_value,v_process_date_value)<0){
				v_status = 0;
				alert('Ngay cap nhat tien do giai quyet khong duoc truoc ngay hien tai('+ v_current_date_value +').');
				obj_date_process.focus();
				return 0;
			}
			break;
		}
	}
	if(v_status == 1){
		btn_save_onclick('UPDATE_RECORD_WORK');
	}
}